<script>
    function add_info() {
        var title = $("#title").val();
        var keywords = $("#keywords").val();
        var tags = $("#tags").val();
        var src_type = $("#src_type").val();
        var id_spec = $("#id_spec").val();
        var logo = $("#logo").val();
        var cnt_md = $("#cnt_md").val();
        var gcat1 = $("#gcat1").val();
        var gcat2 = $("#gcat2").val();
        var gcat3 = $("#gcat3").val();
        var gcat4 = $("#gcat4").val();
        var gcat5 = $("#gcat5").val();
        $.post("/post/p/add_document", {
            title: title, keywords: keywords, tags: tags,
            src_type: src_type, id_spec: id_spec, logo: logo, cnt_md: cnt_md,
            gcat1: gcat1, gcat2: gcat2, gcat3: gcat3, gcat4: gcat4, gcat5: gcat5
        }, function (result) {
        });
        $("#addinfo").html("添加成功");
    }
</script>
<script type="text/javascript" src="{{ static_url('f2elib/jquery-validate_1.15.0/jquery.validate.min.js') }}"></script>
<script type="text/javascript" src="{{ static_url('jslib/dst/gscript.js') }}"></script>
<div class="row">
    <div class="col-md-10">
        <div class="panel panel-default">
            <div class="panel-heading"><span class="glyphicon glyphicon-envelope"></span> 添加信息</div>
            <div class="panel-body">
                <div class="content" id="addinfo">
                    <form class="form-horizontal" id="form_add">
                        <input type=hidden name=uid value="{{ kwd['uid'] }}">
                        <fieldset>
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="title">标题</label>

                                <div class="col-md-9">
                                    <input class="form-control" id="title" type="text" name="title">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label" for="tags">标签</label>

                                <div class="col-md-9">
                                    <input class="form-control" id="tags" name="tags" type="text"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="src_type">文档类型</label>

                                <div class="col-md-9">
                                    <select id="src_type" name="src_type" class="form-control">
                                        <option value="0" selected>MarkDown</option>
                                        <option value="1">RestructedText</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="logo">特色图片</label>

                                <div class="col-md-9">
                                    <input class="form-control" id="logo" name="logo" type="text">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="up"></label>

                                <div class="col-md-9">
                                    <label id="up"><a href="/entry/add" target="_blank">上传图片</a></label>
                                </div>
                            </div>
                            {% for ii in range(0,5) %}
                            <div class="form-group">
                                {% if ii == 0 %}
                                <label for="pcat0" class="col-sm-3 control-label">分类</label>
                                {% else %}
                                <label for="pcatx" class="col-sm-3 control-label"></label>
                                {% end %}
                                <div class="col-sm-3">
                                    <select name="pcat{{ii}}" id="pcat{{ii}}" class="form-control"
                                            onchange="g_load_postcat({{ii}})">
                                        <option value="">请选择</option>
                                        {% for taginfo in tag_infos %}
                                        {% if taginfo.uid.endswith('00') %}
                                        <option value="{{ taginfo.uid }}">{{ taginfo.name }}
                                        </option>
                                        {% else %}
                                        {% end %}
                                        {% end %}
                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <select name="gcat{{ii}}" id="gcat{{ii}}" class="form-control">
                                    </select>
                                </div>
                            </div>
                            {% end %}
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="cnt_md">内容 (下面输入内容，使用MarkDown语法)</label>

                                <div class="col-md-9">
                                    <textarea rows=13 id="cnt_md" name="cnt_md" cols="80"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-3 control-label"></label>

                                <div class="col-md-9">
                                    <button onclick="add_info()" class="btn btn-default btn-md">添加</button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
